package org.openkoala.koala.wizard.wizardpage;

import org.eclipse.core.resources.IWorkspaceRoot;
import org.eclipse.core.resources.ResourcesPlugin;
import org.eclipse.jface.dialogs.Dialog;
import org.eclipse.jface.wizard.WizardPage;
import org.eclipse.swt.SWT;
import org.eclipse.swt.layout.GridData;
import org.eclipse.swt.layout.GridLayout;
import org.eclipse.swt.widgets.Composite;
import org.eclipse.swt.widgets.Label;

public class TestWizardPage extends WizardPage {

	private IWorkspaceRoot workspaceRoot;
	
	public TestWizardPage() {
		super("代码生成-新建一个空项目");
		setTitle("代码生成-新建一个空项目");
		setDescription("代码生成-新建一个空项目");
		setPageComplete(false);
		workspaceRoot = ResourcesPlugin.getWorkspace().getRoot();
	}

	/**
	 * @see org.eclipse.jface.dialogs.IDialogPage#createControl(org.eclipse.swt.widgets.Composite)
	 */
	public void createControl(Composite parent) {
		initializeDialogUnits(parent);

		final Composite composite = createClientArea(parent);

		createLabel(composite);

		setControl(composite);
		Dialog.applyDialogFont(composite);
	}

	/**
	 * 创建一个用户区域
	 * 
	 * @param composite
	 * @return
	 */
	private Composite createClientArea(Composite composite) {
		Composite composite1 = new Composite(composite, SWT.NONE);
		GridLayout gridlayout = new GridLayout();
		gridlayout.marginWidth = 0;
		gridlayout.marginHeight = 0;
		gridlayout.numColumns = 3;
		composite1.setLayout(gridlayout);
		return composite1;
	}

	/**
	 * 创建一个Label
	 * 
	 * @param composite
	 */
	private void createLabel(Composite composite) {
		Label label = new Label(composite, 64);
		label.setText("Label测试");
		GridData griddata = new GridData();
		griddata.widthHint = convertWidthInCharsToPixels(80);
		griddata.horizontalSpan = 3;
		label.setLayoutData(griddata);
	}
}
